<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Settings_model extends WS_model
{
    public function get_AllSettings($private = NULL, $return_array = false)
    {
        $this->db->from('setting');
        if (!is_null($private))
            $this->db->where('setting_private', $private);
        $this->db->order_by('setting_seq_id', 'asc');
        if($return_array) {
            $this->db->select('setting_key,setting_value');
            return $this->result_array();
        }
        $query = $this->db->get();
        if ($query->num_rows()) {
            $r = array();
            foreach ($query->result() as $x) {
                $r[$x->setting_key] = $x;
            }
            return $r;
        }
        return false;
    }

    public function update_BatchSettings($data, $key)
    {
        $this->db->update_batch('setting', $data, $key);
        return $this->db->affected_rows();
    }
}